import { mongo } from 'mongoose'
import { createBaseMongoClient } from '../controller/mongodb'
import { DailyReportInterface, FaucetInterface, FiveMinitesReportInterface, HourlyReportInterface, LastPaidInterface } from '../model'
import { ClientInterface } from '../model'
export * from "../db/db"
export * from "./router"




export async function createDBClient(config: { uri: string, db: string }): Promise<ClientInterface> {
    const { uri = "mongodb://172.16.0.104", db = "faucet" } = config
    const faucetClient = await createBaseMongoClient<FaucetInterface>({ uri, db, col: 'faucet' })
    const hourClient = await createBaseMongoClient<HourlyReportInterface>({ uri, db, col: 'hourly_report' })
    const dailyClient = await createBaseMongoClient<DailyReportInterface>({ uri, db, col: 'daily_report' })
    const fiveClient = await createBaseMongoClient<FiveMinitesReportInterface>({ uri, db, col: 'five_report' })
    const lastClient = await createBaseMongoClient<LastPaidInterface>({ uri, db, col: "last_paid_report" })
    const clients: ClientInterface = {
        faucetClient: faucetClient,
        fiveClient: fiveClient,
        hourClient: hourClient,
        dailyClient: dailyClient,
        lastClient: lastClient
    }

    return clients
}
